package hotel.meituan.oversea.biz.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import hotel.base.oversea.constant.CommonConstants;
import hotel.base.oversea.constant.CommonUrlConstants;
import hotel.base.oversea.constant.MeituanConstants;
import hotel.base.oversea.constant.enums.CommonEnums;
import hotel.base.oversea.constant.enums.MtHotelEnums;
import hotel.base.oversea.constant.quartz.UrlSwitchsEnums;
import hotel.base.oversea.dto.meituan.MtHotelRoomBedInfoDto;
import hotel.base.oversea.dto.meituan.MtHotelRoomDto;
import hotel.base.oversea.dto.meituan.MtRoomInfoDto;
import hotel.base.oversea.entity.MtHotelRoomBedInfo;
import hotel.base.oversea.service.impl.BaseServiceImpl;
import hotel.base.oversea.utils.GsonUtils;
import hotel.base.oversea.utils.HttpClientBaseAuth;
import hotel.base.oversea.utils.Result;
import hotel.base.oversea.vo.meituan.request.room.MtHotelRealRoomBaseInfoVo;
import hotel.base.oversea.vo.meituan.request.room.MtHotelRealRoomBedInfoVo;
import hotel.base.oversea.vo.meituan.request.room.MtHotelRealRoomVo;
import hotel.base.oversea.vo.meituan.request.room.MtHotelRoomVo;
import hotel.meituan.oversea.api.entity.MtHotelRoom;
import hotel.meituan.oversea.api.vo.switchs.ModifyStatusVo;
import hotel.meituan.oversea.api.vo.up.response.goods.MtHotelGoodsStatusDetailCallbackVo;
import hotel.meituan.oversea.biz.config.service.RedisService;
import hotel.meituan.oversea.biz.mapper.MtHotelRoomBedInfoMapper;
import hotel.meituan.oversea.biz.mapper.MtHotelRoomMapper;
import hotel.meituan.oversea.biz.service.MtHotelGoodsService;
import hotel.meituan.oversea.biz.service.MtHotelRoomService;
import hotel.meituan.oversea.biz.task.MeituanSaveApiLogTask;
import hotel.meituan.oversea.biz.utils.MtUtils;
import hotel.meituan.oversea.biz.utils.RestTemplateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
import tk.mybatis.mapper.entity.Example;

import java.util.*;

@Slf4j
@Service
public class MtHotelRoomServiceImpl extends BaseServiceImpl implements MtHotelRoomService {
    @Autowired
    private MtHotelRoomMapper mtHotelRoomMapper;
    @Autowired
    private MtHotelRoomBedInfoMapper mtHotelRoomBedInfoMapper;
    @Autowired
    private MtHotelGoodsService mtHotelGoodsService;
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private RedisService redisService;
    //公共参数
    private  String version = MeituanConstants.VERSION;//版本号
    private  int partnerId = MeituanConstants.BUSINESS_ID;//平台分配给第三方渠道的分销业务ID
    private  String accesskey = MeituanConstants.ACCESS_KEY;//平台分配给第三方渠道的安全凭证公钥
    private String apiUrl = MeituanConstants.URL;//请求接口地址

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    MeituanSaveApiLogTask meituanSaveApiLogTask;


    /**
     * 请求获取物理房型数据
     * @param hotelIds 酒店ids
     * @desc
     */
    @Override
    public Result<Object> getMtHotelRoom(List<Long> hotelIds) {
        //业务参数
        String data = "";
        Map<String,Object> dataMap = new HashMap<>();
        dataMap.put("hotelIds",hotelIds);
        data = JSON.toJSONString(dataMap);
        //发起请求
        String response = MtUtils.createParamsPost(data, MtHotelEnums.apiMethodEnum.METHOD_HOTEL_ROOM.getMethod(),meituanSaveApiLogTask);
        //处理响应数据
        JSONObject responseJson = JSON.parseObject(response);
        if("0".equals(String.valueOf(responseJson.get("code")))){
            String result = responseJson.getString("result");
            if(null != result){
                MtHotelRoomVo mtHotelRoomVo = null;
                try {
                    mtHotelRoomVo = JSON.parseObject(result,MtHotelRoomVo.class);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if(null == mtHotelRoomVo){
                    log.error("////////////////MTAPIERROR///////////////////酒店物理房型接口数据异常 result parse vo error");
                    return new Result<>("parse error",CommonConstants.PARSE_ERROR);
                }else{
                    return new Result<>(mtHotelRoomVo.getRealRoomInfos());
                }

            }else{
                //物理房型数据可能为空
                return new Result<>();
            }
        }else{
            return new Result<>(responseJson.getString("message"),CommonConstants.REQUEST_ERROR);
        }
    }

    @Override
    public Result<Object> getMtHotelRoomByHotelId(String mtHotelId) {
        List<Long> hotelIds = new ArrayList<>();
        hotelIds.add(Long.valueOf(mtHotelId));
        Result rs = this.getMtHotelRoom(hotelIds);
        if(rs.getCode()==CommonConstants.SUCCESS){
            List<MtRoomInfoDto> roomList = new ArrayList<>();
            if(null != rs.getData()){
                Map<Long, List<MtHotelRealRoomVo>> realRoomInfos = (Map<Long, List<MtHotelRealRoomVo>>)rs.getData();
                if(null != realRoomInfos && realRoomInfos.size()>0){
                    for (Map.Entry m:realRoomInfos.entrySet()){
                        List<MtHotelRealRoomVo> thisOneHotelRoomInfos = (List<MtHotelRealRoomVo>)m.getValue();
                        for (MtHotelRealRoomVo room:thisOneHotelRoomInfos){
                            Integer realRoomId = room.getRealRoomBaseInfo().getRealRoomId();
                            String roomName = room.getRealRoomBaseInfo().getRoomName();
                            MtRoomInfoDto mtRoomInfoDto = new MtRoomInfoDto();
                            mtRoomInfoDto.setRoomId(realRoomId);
                            mtRoomInfoDto.setRoomName(roomName);
                            mtRoomInfoDto.setWindow(room.getRealRoomBaseInfo().getWindow());
                            roomList.add(mtRoomInfoDto);
                        }
                    }

                }
            }
            return new Result<>(GsonUtils.GsonString(roomList),"success");
        }else{
            return rs;
        }
    }

    /**
     * 保存酒店房型数据+床型数据
     * @param
     * @param mapRealRoomVoMap
     * @return
     */
    @Override
    public Result<Object> saveRoomData(Map<Long, List<MtHotelRealRoomVo>> mapRealRoomVoMap){
        List<MtHotelRoom> roomEntityList = new ArrayList<>();
        List<MtHotelRoomBedInfo> bedInfoEntityList = new ArrayList<>();
        //Map redisMap = new HashMap();
        Map<String,List<MtHotelRoomBedInfoDto>> putRedisBedInfoMap = new HashMap();
        //map ：key 酒店ID，value酒店对应物理房型数据list
        Map<Long,Long> hotelIdsMap = new HashMap<>();
        for (Map.Entry<Long, List<MtHotelRealRoomVo>> hotelJoinRoomDataEntry : mapRealRoomVoMap.entrySet()) {
            //遍历每个酒店，处理值酒店的物理房型数据
            List<MtHotelRealRoomVo> thisHotelRoomListVo = new ArrayList<>();
            thisHotelRoomListVo = hotelJoinRoomDataEntry.getValue();
            for (MtHotelRealRoomVo roomVo:thisHotelRoomListVo){
                MtHotelRealRoomBaseInfoVo thisRoomBaseInfoVo = roomVo.getRealRoomBaseInfo();
                Long hotelId = hotelJoinRoomDataEntry.getKey();
                hotelIdsMap.put(hotelId,hotelId);
                MtHotelRoom roomEntity = new MtHotelRoom();
                roomEntity.setId(String.valueOf(UUID.randomUUID()));
                roomEntity.setMtHotelId(String.valueOf(hotelId));
                roomEntity.setMtRoomId(String.valueOf(thisRoomBaseInfoVo.getRealRoomId()));
                roomEntity.setMtRoomName(thisRoomBaseInfoVo.getRoomName());
                roomEntity.setMtRoomType(thisRoomBaseInfoVo.getRoomType());
                String roomDesc = thisRoomBaseInfoVo.getRoomDesc();//再次判断不然存值异常
                if(!StringUtils.isEmpty(roomDesc)){
                    roomEntity.setMtRoomDesc(roomDesc);
                }
                roomEntity.setMtUseableArea(thisRoomBaseInfoVo.getUseableArea());
                roomEntity.setMtCapacity(thisRoomBaseInfoVo.getCapacity());
                roomEntity.setMtWindow(thisRoomBaseInfoVo.getWindow());
                String windowDesc = thisRoomBaseInfoVo.getWindowView();
                if(!StringUtils.isEmpty(windowDesc)){
                    roomEntity.setMtWindowView(String.valueOf(thisRoomBaseInfoVo.getWindowView()));
                }
                String windowBad = thisRoomBaseInfoVo.getWindowBad();//再次判断不然存值异常
                if(!StringUtils.isEmpty(windowBad) && !windowBad.equals("[]")){//第三方问题空值时返回 windowBad": "[]"
                    try{
                        roomEntity.setMtWindowBad(Integer.valueOf(windowBad));//上游有时候返回数组有时候发返回字符串  [4] 4
                    }catch (Exception e){
                        List<Integer> win = JSON.parseArray(windowBad,Integer.class);
                        roomEntity.setMtWindowBad(win.get(0));
                    }
                }
                roomEntity.setMtFloor(thisRoomBaseInfoVo.getFloor());
                roomEntity.setMtInternetWay(thisRoomBaseInfoVo.getInternetWay());
                roomEntity.setMtStatus(String.valueOf(thisRoomBaseInfoVo.getStatus()));
                roomEntity.setState(CommonEnums.STATE_NORMAL.getCode());
                roomEntity.setRemark("");
                roomEntity.setCreateTime(new Date());
                roomEntity.setModifyTime(new Date());
                roomEntityList.add(roomEntity);
                List<List<MtHotelRealRoomBedInfoVo>> thisRoomBedInfoVoListList = roomVo.getRoomBedInfoList();
                /**
                 * {
                 *     "roomBedInfoList":[
                 *         Array[1],
                 *         Array[1]
                 *     ]
                 * }
                 * {
                 *     "roomBedInfoList":[
                 *         [
                 *             Object{...},
                 *             Object{...}
                 *         ]
                 *     ]
                 * }
                 */
                if(null != thisRoomBedInfoVoListList){
                    List<MtHotelRoomBedInfoDto> bedList = new ArrayList<>();
                    for (List<MtHotelRealRoomBedInfoVo> thisRoomBedInfoVoList:thisRoomBedInfoVoListList){
                        for (MtHotelRealRoomBedInfoVo bedVo:thisRoomBedInfoVoList){
                            MtHotelRoomBedInfo bedInfoEntity = new MtHotelRoomBedInfo();
                            bedInfoEntity.setId(String.valueOf(UUID.randomUUID()));
                            bedInfoEntity.setMtHotelId(String.valueOf(hotelId));
                            bedInfoEntity.setMtRoomId(String.valueOf(bedVo.getRoomId()));
                            bedInfoEntity.setMtBedType(bedVo.getBedType());
                            bedInfoEntity.setMtBedDesc(bedVo.getBedDesc());
                            bedInfoEntity.setMtBedCount(String.valueOf(bedVo.getBedCount()));
                            bedInfoEntity.setState(CommonEnums.STATE_NORMAL.getCode());
                            bedInfoEntity.setRemark("");
                            bedInfoEntity.setCreateTime(new Date());
                            bedInfoEntity.setModifyTime(new Date());
                            bedInfoEntityList.add(bedInfoEntity);

                            MtHotelRoomBedInfoDto mtHotelRoomBedInfoDto = new MtHotelRoomBedInfoDto();
                            mtHotelRoomBedInfoDto.setMtRoomId(String.valueOf(bedVo.getRoomId()));
                            mtHotelRoomBedInfoDto.setMtBedType(bedInfoEntity.getMtBedType());
                            mtHotelRoomBedInfoDto.setMtBedDesc(bedInfoEntity.getMtBedDesc());
                            mtHotelRoomBedInfoDto.setMtBedCount(bedInfoEntity.getMtBedCount());
                            bedList.add(mtHotelRoomBedInfoDto);
                        }
                    }
                    putRedisBedInfoMap.put(String.valueOf(thisRoomBaseInfoVo.getRealRoomId()),bedList);
                }
                /*MtHotelRoomDto mtHotelRoomDto = new MtHotelRoomDto();
                mtHotelRoomDto.setMtHotelId(roomEntity.getMtHotelId());
                mtHotelRoomDto.setMtRoomId(roomEntity.getMtRoomId());
                mtHotelRoomDto.setMtRoomName(roomEntity.getMtRoomName());
                mtHotelRoomDto.setMtRoomType(roomEntity.getMtRoomType());
                mtHotelRoomDto.setMtRoomDesc(roomEntity.getMtRoomDesc());
                mtHotelRoomDto.setMtUseableArea(roomEntity.getMtUseableArea());
                mtHotelRoomDto.setMtCapacity(roomEntity.getMtCapacity());
                mtHotelRoomDto.setMtWindow(roomEntity.getMtWindow());
                mtHotelRoomDto.setMtFloor(roomEntity.getMtFloor());
                mtHotelRoomDto.setMtInternetWay(roomEntity.getMtInternetWay());
                mtHotelRoomDto.setMtStatus(roomEntity.getMtStatus());
                redisMap.put(mtHotelRoomDto.getMtHotelId()+","+mtHotelRoomDto.getMtRoomId(),mtHotelRoomDto);*/
            }
        }
        Map map = new HashMap();
        StringBuffer sb = new StringBuffer();
        int i = 0;
        for (Map.Entry<Long, Long> id: hotelIdsMap.entrySet()) {
            i += 1;
            sb.append("'"+id.getKey()+"'");//拼接单引号,到数据库后台用in查询.
            if(i!=hotelIdsMap.size()){
                sb.append(",");
            }
        }
        map.put("hotelIds",sb.toString());
        int roDel = mtHotelRoomMapper.deleteBatchRoomByHotelId(map);
        if(roDel != -1){
            mtHotelRoomMapper.insertList(roomEntityList);
        }
        int beDel = mtHotelRoomBedInfoMapper.deleteBatchBedByHotelId(map);
        if(beDel!=-1){
            mtHotelRoomBedInfoMapper.insertList(bedInfoEntityList);
        }
        //将物理房型数据保存到redis(for对数据)
                    /*Map<String,MtHotelRoomDto> putMap = (Map<String,MtHotelRoomDto>)redisService.get(CommonConstants.MEITUAN_HOTEL_ROOM);
                    if(null != putMap && putMap.size()>0){
                        putMap.putAll(redisMap);
                    }else{
                        putMap=redisMap;
                    }
                    redisService.set(CommonConstants.MEITUAN_HOTEL_ROOM,putMap);*/
         //将房型的床型数据保存到redis(for对数据)
        if(null != putRedisBedInfoMap && putRedisBedInfoMap.size()>0){
            Map<String,List<MtHotelRoomBedInfoDto>> redisBedMap = (Map<String,List<MtHotelRoomBedInfoDto>>)redisService.get(CommonConstants.MEITUAN_HOTEL_ROOM_BED);
            if(null != redisBedMap && redisBedMap.size()>0){
                redisBedMap.putAll(putRedisBedInfoMap);
            }else{
                redisBedMap=putRedisBedInfoMap;
            }
            redisService.set(CommonConstants.MEITUAN_HOTEL_ROOM_BED,redisBedMap);
        }
        return new Result<>(mapRealRoomVoMap);
    }

    @Override
    public Result<MtHotelRoomDto> getMtHotelRoomById(String mtHotelId,String roomId) {
        /*MtHotelRoom r = new MtHotelRoom();
        r.setMtRoomId(roomId);
        r.setMtHotelId(mtHotelId);
        r = mtHotelRoomMapper.selectOne(r);
        if(null != r && null != r.getMtRoomId()){
            MtHotelRoomDto dto = new MtHotelRoomDto();
            BeanUtils.copyProperties(r,dto);
            return new Result<>(dto);
        }else{
            return new Result<>();
        }*/
        List<Long> hotelIds = new ArrayList<>();
        hotelIds.add(Long.valueOf(mtHotelId));
        Result result = this.getMtHotelRoom(hotelIds);
        if(result.getCode()==CommonConstants.SUCCESS){
            Map<Long, List<MtHotelRealRoomVo>> realRoomInfos = (Map<Long, List<MtHotelRealRoomVo>>)result.getData();
            if(null != realRoomInfos && realRoomInfos.size()>0){
                for (Map.Entry m:realRoomInfos.entrySet()){
                    List<MtHotelRealRoomVo> list = (List<MtHotelRealRoomVo>)m.getValue();
                    if(null != list && list.size()>0){
                        for (MtHotelRealRoomVo r:list){
                            String nowid = String.valueOf(r.getRealRoomBaseInfo().getRealRoomId());
                            if(nowid.equals(roomId)){
                                MtHotelRealRoomBaseInfoVo baseInfoVo = r.getRealRoomBaseInfo();
                                MtHotelRoomDto dto = new MtHotelRoomDto();
                                dto.setMtHotelId(mtHotelId);
                                dto.setMtRoomId(roomId);
                                dto.setMtCapacity(baseInfoVo.getCapacity());
                                dto.setMtExtraBed(baseInfoVo.getExtraBed());
                                dto.setMtFloor(baseInfoVo.getFloor());
                                dto.setMtInternetWay(baseInfoVo.getInternetWay());
                                dto.setMtRoomDesc(baseInfoVo.getRoomDesc());
                                dto.setMtRoomName(baseInfoVo.getRoomName());
                                dto.setMtRoomType(baseInfoVo.getRoomType());
                                dto.setMtStatus(String.valueOf(baseInfoVo.getStatus()));
                                dto.setMtUseableArea(baseInfoVo.getUseableArea());
                                dto.setMtWindow(baseInfoVo.getWindow());
                                String windowBad = baseInfoVo.getWindowBad();//再次判断不然存值异常
                                if(!StringUtils.isEmpty(windowBad) && !windowBad.equals("[]")){//第三方问题空值时返回 windowBad": "[]"
                                    try{
                                        dto.setMtWindowBad(Integer.valueOf(windowBad));//上游有时候返回数组有时候发返回字符串  [4] 4
                                    }catch (Exception e){
                                        List<Integer> win = JSON.parseArray(windowBad,Integer.class);
                                        dto.setMtWindowBad(win.get(0));
                                    }
                                }
                                dto.setMtWindowView(baseInfoVo.getWindowView());
                                return new Result<>(dto,"success");
                            }
                        }
                    }
                }
            }
        }
        return new Result<>("未发现roomid信息",CommonConstants.SUCCESS);

    }

    @Override
    public Result<List<MtHotelRoomBedInfoDto>> getMtHotelRoomBedInfoById(String mtHotelId,String roomId) {
        Example example = new Example(MtHotelRoomBedInfo.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("mtRoomId",roomId);
        criteria.andEqualTo("mtHotelId",mtHotelId);
        List<MtHotelRoomBedInfo> all = mtHotelRoomBedInfoMapper.selectByExample(example);
        List<MtHotelRoomBedInfoDto> dtoList = new ArrayList<>();
        if(null != all && all.size()>0){
            for (MtHotelRoomBedInfo entity:all){
                MtHotelRoomBedInfoDto dto = new MtHotelRoomBedInfoDto();
                BeanUtils.copyProperties(entity,dto);
                dtoList.add(dto);
            }
            return new Result<>(dtoList);
        }
        return new Result<>(dtoList);
    }

    @Override
    public Result<Object> dealNotifyRoomFromJob(List<MtHotelGoodsStatusDetailCallbackVo> rsManyHotelList) {//用途1、定时器处理notifystate数据，参数是list但实际job传的是size=1的集合
        log.info("进入保存更新变更的房态信息，MtHotelRoomServicelmpl dealNotifyRoomFromJob {}", JSON.toJSONString(rsManyHotelList));
        //Map<String,Integer> changeMap = new HashMap();
        List<ModifyStatusVo> modifyStatusChangeVoList = null;
        for (MtHotelGoodsStatusDetailCallbackVo stateByOneHotel:rsManyHotelList){//每遍历一组为：  hotel - goods - statusList   1-1-多
            Integer hotelId = stateByOneHotel.getHotelId();
            Integer goodsId = stateByOneHotel.getGoodsId();

            //判断是否对比是否售卖房型
            if(mtHotelGoodsService.requestGetSwitchsSaleRoomByMtGoodsInfo(goodsId,String.valueOf(hotelId))){
                /*List<MtHotelGoodsStatusDetailBaseCallbackVo> detailBaseList = stateByOneHotel.getGoodsStatuses();
                if(null != detailBaseList && detailBaseList.size()>0){
                    modifyStatusChangeVoList = new ArrayList<>();
                    List<MtHotelGoodsStatus> goodsEntityList = new ArrayList<>();
                    for (MtHotelGoodsStatusDetailBaseCallbackVo detailBase:detailBaseList){
                        MtHotelGoodsStatus goodsStatusEntity = new MtHotelGoodsStatus();
                        goodsStatusEntity.setId(UUID.randomUUID().toString());
                        goodsStatusEntity.setMtHotelId(String.valueOf(hotelId));
                        goodsStatusEntity.setMtGoodsId(String.valueOf(goodsId));
                        goodsStatusEntity.setMtGoodsStatus(detailBase.getStatus());
                        goodsStatusEntity.setMtCheckState(detailBase.getStatus());
                        goodsStatusEntity.setMtCheckDate(detailBase.getDate());
                        goodsStatusEntity.setState(CommonEnums.STATE_NORMAL.getCode());
                        goodsStatusEntity.setCreateTime(new Date());
                        goodsStatusEntity.setModifyTime(new Date());
                        goodsEntityList.add(goodsStatusEntity);
                        //changeMap.put(goodsId+","+detailBase.getDate(),detailBase.getStatus());

                        ModifyStatusVo v = new ModifyStatusVo();
                        v.setMtHotelId(hotelId);
                        v.setMtGoodId(goodsId);
                        //携程接口status 0 满房(美团的0，2，3归类于0) 1可预定
                        Integer thisState = 1;
                        if(0== detailBase.getStatus() || 2 == detailBase.getStatus() || 3 == detailBase.getStatus()){
                            thisState = 0;
                        }
                        v.setStatus(thisState);
                        v.setTime(detailBase.getDate());
                        modifyStatusChangeVoList.add(v);

                    }
                    mtHotelGoodsService.saveGoodsStatus(goodsEntityList,null);

                    //list中是多个酒店的statu数据，每次构建完一个酒店的statu数据就上送给携程，因为携程的status批量接口要求同一个酒店
                    //2、其他业务代码（调用携程）
                    //推送给携程发送房态变更
                    if(null != modifyStatusChangeVoList && modifyStatusChangeVoList.size()>0){
                        //处理当前这一批上游推送的产品房态变化数据,推送给携程外放接口
                        this.requestNoticeSwitchsUpdateRoomChange(modifyStatusChangeVoList);
                    }
                }*/
            }else{
                log.info("进入保存更新变更的房态信息，MtHotelRoomServicelmpl dealNotifyRoomFromJob 最后一次校验是否存在售卖房型不通过，不处理：{}", JSON.toJSONString(stateByOneHotel));
            }
        }


        return new Result<>();
    }

    public void requestNoticeSwitchsUpdateRoomChange(List<ModifyStatusVo>  modifyStatusVoList){
        log.info("Meituan Deal Notify Rs Goods State Change Task 进入mtHotelRoomServiceImpl >>>>>>>>> 通知携程房态变更 requestNoticeSwitchsUpdateRoomChange 开始执行时间：{},{}",hotel.base.oversea.utils.DateUtil.getNowTime(), JSON.toJSONString(modifyStatusVoList));
        String accessToken = HttpClientBaseAuth.getAuthToken();
        String switchsHost = CommonUrlConstants.SWITCHS_HOST;
        //批量
        String updateSwitchChangeBatchRoomUrl = switchsHost + UrlSwitchsEnums.switchRoom.UPDATE_ROOM_BATCH_CHANGE.getValue();//+"?access_token="+accessToken;//
        if(null != modifyStatusVoList && modifyStatusVoList.size()>0){
            requestSwitchsUpdateStateBatchApi(updateSwitchChangeBatchRoomUrl,modifyStatusVoList);
        }

        /*
        String updateSwitchChangeRoomUrl = switchsHost + UrlSwitchsEnums.switchRoom.UPDATE_ROOM_CHANGE.getValue()+"?access_token="+accessToken;
        for (Map.Entry vo:changeInfos.entrySet()){
            String goodsId = ((String) vo.getKey()).split(",")[0];
            String date = ((String) vo.getKey()).split(",")[1];
            Integer state = (Integer)vo.getValue();
            //携程接口status 0 满房(美团的0，2，3归类于0) 1可预定
            if(0== state || 2 == state || 3 == state){
                state = 0;
            }
            //requestSwitchsApi(updateSwitchChangeRoomUrl,Integer.valueOf(goodsId),date,state);单个
            try{
                Thread.currentThread().sleep(3000);
            }catch (Exception e){
                log.error(e.getMessage(),e);
            }
        }*/

        log.info("Meituan Deal Notify Rs Goods State Change Task 进入mtHotelRoomServiceImpl>>>>>>>>> requestNoticeSwitchsUpdateRoomChange 结束执行时间：{}",hotel.base.oversea.utils.DateUtil.getNowTime());
    }
    public void requestSwitchsUpdateStateBatchApi(String updateSwitchChangeRoomUrl,List<ModifyStatusVo> modifyStatusVoList){
        Map params = new HashMap();
        params.put("modifyStatusVoList",modifyStatusVoList);
        log.info("Meituan Deal Notify Rs Goods State Change Task 进入接口mtHotelRoomServiceImpl>>>>>>>>>通知携程房态变更 调用携程同一酒店批量修改房态接口 " +
                "mtHotelRoomServiceImpl.requestSwitchsApi：{},{}", JSON.toJSONString(params), hotel.base.oversea.utils.DateUtil.getNowTime());
        Result response = RestTemplateUtils.post(updateSwitchChangeRoomUrl, JSON.toJSONString(params),restTemplate);
        log.info("Meituan Deal Notify Rs Goods State Change Task 进入接口mtHotelRoomServiceImpl 通知携程房态变 调用携程修改房态接口  mtHotelRoomServiceImpl.requestSwitchsApi 返回：{},{},{}",response, JSON.toJSONString(params), JSON.toJSONString(modifyStatusVoList));
        if(response.getCode() == CommonConstants.SUCCESS){

        }else{

        }
    }

    public void requestSwitchsApi(String updateSwitchChangeRoomUrl,Integer goodsId,String date,Integer state){
        Map params = new HashMap();
        params.put("mtGoodId",goodsId);
        params.put("status",state);
        params.put("time",date);
        log.info("Meituan Deal Notify Rs Goods State Change Task 进入接口mtHotelRoomServiceImpl>>>>>>>>>通知携程房态变更 调用携程修改房态接口 " +
                "mtHotelRoomServiceImpl.requestSwitchsApi：{},{}", JSON.toJSONString(params), hotel.base.oversea.utils.DateUtil.getNowTime());
        Result response = RestTemplateUtils.post(updateSwitchChangeRoomUrl, JSON.toJSONString(params),restTemplate);
        if(response.getCode() == CommonConstants.SUCCESS){

        }else{
            log.info("Meituan Deal Notify Rs Goods State Change Task 进入接口mtHotelRoomServiceImpl 通知携程房态变 调用携程修改房态接口  mtHotelRoomServiceImpl.requestSwitchsApi 请求失败：{}",response);
        }
    }

}
